import { createApp } from 'vue'
import router from './router'
import App from './App.vue';
import ElementPlus from 'element-plus';
import Utils from '@/utils'
import { ElMessage, ElNotification } from 'element-plus';
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import './theme/css/style.scss';

import LayoutBody from '@/Layouts/LayoutBody.vue';
import LayoutBodyTabs from '@/Layouts/LayoutBodyTabs.vue';

import * as ElementPlusIconsVue from '@element-plus/icons-vue'

import { ComponentsPlugin } from '@/components'

import {useMenus} from '@/store'

const app = createApp(App);
app.use(router)
app.use(ElementPlus, {
  locale: zhCn,
})
app.config.globalProperties.$utils = Utils;
app.config.globalProperties.$message = ElMessage;
app.config.globalProperties.$notice = ElNotification;

app.component('layout-body', LayoutBody)
app.component('layout-body-tabs', LayoutBodyTabs)

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
app.directive('permission', (el, binding, vnode) => {
  if (binding.value !== false && binding.value !== '' && useMenus().getPermissionAction !== -1 && useMenus().getPermissionAction!.indexOf(binding.value) === -1){
    el.parentNode && el.parentNode.removeChild(el);
  }
})
app.use(ComponentsPlugin)

app.mount('#app');
